Passed
Pull Request — master (#160)
by
unknown
01:53
created

ID3Util.ts ➔ processUnsynchronisedBuffer   A

Complexity

Conditions 4

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 13
rs 9.9
c 0
b 0
f 0
cc 4
1
import { FrameOptions, FRAME_OPTIONS } from './definitions/FrameOptions'
2
import { isKeyOf } from './util'
3
4
export function getFrameOptions(frameIdentifier: string): FrameOptions {
5
    if (isKeyOf(frameIdentifier, FRAME_OPTIONS)) {
6
        return FRAME_OPTIONS[frameIdentifier]
7
    }
8
    return {
9
        multiple: false
10
    }
11
}
12
13
export function processUnsynchronisedBuffer(buffer: Buffer) {
14
    const newDataArr = []
15
    if (buffer.length > 0) {
16
        newDataArr.push(buffer[0])
17
    }
18
    for(let i = 1; i < buffer.length; i++) {
19
        if (buffer[i - 1] === 0xFF && buffer[i] === 0x00) {
20
            continue
21
        }
22
        newDataArr.push(buffer[i])
23
    }
24
    return Buffer.from(newDataArr)
25
}
26